home *** CD-ROM | disk | FTP | other *** search
/ Interactive Web Graphics with Shout 3D / Interactive Web Graphics With Shout 3D.iso / mac / Code / Chapter09 / ChangeScenesPanel.java < prev    next >
Text File  |  2000-08-29  |  1KB  |  70 lines

  1. package applets;
  2.  
  3. import shout3d.*;
  4. import shout3d.core.*;
  5. import shout3d.math.*;
  6.  
  7. public class ChangeScenesPanel extends Shout3DPanel implements DeviceObserver{
  8.  
  9.    //must create an array (list) of URLs,
  10.    // even though there is only one URL in the array
  11.    String[] URL = new String[1];
  12.    
  13.    Transform ratpack;
  14.    Transform modswing;
  15.    boolean mod = true;
  16.  
  17.  
  18.  
  19.    public ChangeScenesPanel(Shout3DApplet applet){
  20.       super(applet);
  21.    }      
  22.  
  23.  
  24.  
  25.  
  26.    public void customInitialize () {
  27.    
  28.       addDeviceObserver(this,"MouseInput", null);
  29.       
  30.       URL[0] = "models/ratpack2.s3d";
  31.       ratpack = new Transform();
  32.       loadURL(URL, ratpack);
  33.       
  34.       modswing = (Transform) getScene();
  35.       
  36.    }
  37.    
  38.    protected void finalize()  { 
  39.       removeDeviceObserver(this,"MouseInput");
  40.  
  41.    }
  42.  
  43.    public boolean onDeviceInput(DeviceInput di, Object userData) {
  44.       MouseInput mi = (MouseInput) di;
  45.       switch (mi.which){
  46.  
  47.          case MouseInput.DOWN:
  48.          
  49.             if(mod) {
  50.             
  51.               setScene(ratpack);
  52.                mod = false;
  53.               return true;
  54.             }
  55.  
  56.             else {
  57.               setScene(modswing);
  58.                mod = true;
  59.               return true;
  60.             }
  61.                         
  62.       }//end of switch
  63.       
  64.       return false;
  65.    }
  66.  
  67.  
  68. }       
  69.  
  70.